package com.xizi.lotterySystem.dao.mapper;

import com.xizi.lotterySystem.dao.dataobject.ActivityDO;
import com.xizi.lotterySystem.service.enumerate.ActivityStatusEnum;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ActivityMapper {
    @Insert("insert into activity (activity_name,description,status) " +
            "values (#{activityName},#{description},#{status})")
    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    int insert(ActivityDO activityDTO);

    @Select("select count(*) from activity")
    Long selectCount();

    @Select("select * from activity order by id desc limit #{pageSize} offset #{offset}")
    List<ActivityDO> selectList(int pageSize, long offset);

    @Select("select * from activity where id = #{activityId}")
    ActivityDO selectById(Long activityId);

    @Update("update activity set status = #{status} where id = #{id}")
    int updateStatus(Long id, ActivityStatusEnum status);
}
